<template>
  <div style="flex-direction: column;display: flex;">

    <div style="display: flex; flex-direction: column;justify-content: space-between;align-items: center">
      <el-divider/>
      <el-row>
        <el-button @click="change" style="width: 10vw" type="primary">修改资料</el-button>
      </el-row>
      <el-row>
        <el-button @click="toAdmin" style="width: 10vw" type="warning">管理员系统</el-button>
      </el-row>
      <el-row>
        <el-button @click="logout" style="width: 10vw" type="danger">退出登录</el-button>
      </el-row>
    </div>
  </div>
</template>

<script setup>

import {ElMessage} from "element-plus";
import store from "@/store";
import router from "@/router";
const logout = ()=>{
  localStorage.removeItem('token')
  // 获取当前的 Content-Type 属性
  const currentContentType = store.state.authHeader['Content-Type']
  // 构造新的请求头对象
  const newHeader = {
    'Content-Type': currentContentType,
  }
  // 将token添加到请求头中
  store.commit('setAuthHeader', newHeader )
  router.push({
    path: '/',
    headers: store.state.authHeader
  });
  ElMessage.success("退出成功");
}

const change =() =>{
  router.push({name:'Person-change-Profile'})
}

const toAdmin = () =>{
  window.open("/admin","_BLANK")
}

</script>

<style scoped>

</style>